package cn.tedu.es.service;

import cn.tedu.es.entity.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StudentService {
    // Spring 创建动态代理对象
    @Autowired
    private StudentRepository repository;

    public void add(Student student) {
        repository.save(student);
    }

    public void update(Student student) {
        repository.save(student);
    }

    public void deleteById(Long id) {
        repository.deleteById(id);
    }

    public List<Student> findByName(String name) {
        return repository.findByName(name);
    }

    public Page<Student> findByNameOrBirthday(String name, String birthday, Pageable pageable) {
        return repository.findByNameOrBirthday(name, birthday, pageable);
    }
}
